ActiveAdmin.register AlertRule do

  # app/admin/alert_rules.rb
  permit_params :name, :metric, :category, :condition, :threshold, :is_enabled, :description, :frequency

  menu label: '告警规则', priority: 2

  index do
    selectable_column
    column :name
    column :category
    column :metric
    column :condition
    column :threshold
    column :is_enabled
    column :frequency
    actions
  end

  filter :stock_id
  filter :condition
  filter :threshold
  filter :is_enabled

  form do |f|
    f.semantic_errors
    f.inputs '基本设置' do
      f.input :name
      f.input :category
      f.input :metric
      f.input :condition
      f.input :threshold
      f.input :frequency
      f.input :is_enabled
      f.input :description
    end
    f.actions
  end
  # 右侧侧边栏
  sidebar '操作提示', only: [:edit, :new] do
    ul do
      li 'changepercent   阈值 1：代表涨1%'
      li 'buy_change      阈值 1：代表涨1%'
      li 'sell_change     阈值 0：代表达到sell价格'
    end
  end
  show do
    attributes_table do
      row :name
      row :category
      row :metric
      row :condition
      row :threshold
      row :frequency
      row :is_enabled
      row :description
    end
  end

end
